provider: Bedrock non-Anthropic message cleanup and xhigh→max#25189
provider: Bedrock non-Anthropic message cleanup and xhigh→max#25189jackmazac wants to merge 1 commit intoanomalyco:devfrom
Conversation
normalizeMessages strips cachePoint and reasoning for amazon-bedrock models without anthropic/mistral ids; placeholder if assistant empty. Map adaptive xhigh reasoning effort to max for Bedrock; test expects max + display summarized for opus 4.7.
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found several related PRs that address similar concerns around Bedrock message handling and reasoning effort configuration: Related PRs
However, none of these appear to be exact duplicates of the current PR. They address related but distinct issues in the Bedrock provider implementation. |
|
Closing to reopen with a linked issue and the repo PR template per CONTRIBUTING. |
Summary
Some Amazon Bedrock models are not the Anthropic Claude adapter: they use different wire shapes. Sending them Anthropic-style extras—reasoning blocks from another stack, or cache breakpoints their stack does not understand—causes failures or empty turns. Separately, Bedrock’s adaptive “extra high” reasoning knob must map to a value the SDK accepts. This PR tightens Bedrock message shaping and variant config for those cases.
Problem (plain language)
xhigh, but Bedrock’s adaptive config for this path expectsmaxfor that tier—sendingxhighliterally can break or be ignored.Technical breakdown
normalizeMessages(Bedrock npm@ai-sdk/amazon-bedrock, API id withoutanthropicormistral):cachePointfromproviderOptionsunderbedrockandmodel.providerIDbuckets.reasoning/redacted-reasoningparts from assistant array content; if nothing remains, insert a minimal text placeholder.variantsfor@ai-sdk/amazon-bedrockadaptive map:maxReasoningEffort: effort === "xhigh" ? "max" : effort, while preserving upstream Opus 4.7display: "summarized"behavior on thexhighvariant row.Solution
normalizeMessagesbefore interleaved handling for non-Anthropic, non-Mistral Bedrock models.xhigh→maxfor adaptivereasoningConfig.maxReasoningEfforton Bedrock.transform.test.tsso Bedrock Opus 4.7xhighexpectsmaxplusdisplay: "summarized".Files
packages/opencode/src/provider/transform.tspackages/opencode/test/provider/transform.test.tsHow to test
From
packages/opencode:bun typecheck bun test test/provider/transform.test.tsMerge order
Best reviewed after PR #25186 (catalog 200K / 1M split), since users pick the
-1mrows this transform complements. Still compiles independently if merged out of order.